
function changecode(thi){
    thi.src=thi.src+"?"+Math.random();
}

function getpass(){
    var account =document.getElementById("account").value;

    var select = document.getElementById("select");
    var index =select.selectedIndex;
    var option = select.options[index].innerText;

   var accountanser=document.getElementById("accountanser").value;
   var accountcode =document.getElementById("accountcode").value;
    $.ajax({
       url:"getpass",
       type:"post",
       async:true,
       dataType:"json",
       data:{account,option,accountanser,accountcode},
       success:function (data){
           if(data.inf==="成功"){
               changecode(document.getElementById("img"));
                document.getElementById("accountpass").value="";
                document.getElementById("accountpass2").value="";
               $('#myModal').modal('show', 'fit');
           }
       },
       error:function (data){
           alert("请求失败");
       }
   })
}

function passclose(){

    document.getElementById("eyeopen").style.display="none";
    document.getElementById("eyeclose").style.display="block";
    document.getElementById("accountpass").type="password"
}

function passopen(){
    document.getElementById("eyeopen").style.display="block";
    document.getElementById("eyeclose").style.display="none";
    document.getElementById("accountpass").type="text";
}

function passclose2(){
    document.getElementById("eyeopen2").style.display="none";
    document.getElementById("eyeclose2").style.display="block";
    document.getElementById("accountpass2").type="password"
}

function passopen2(){
    document.getElementById("eyeopen2").style.display="block";
    document.getElementById("eyeclose2").style.display="none";
    document.getElementById("accountpass2").type="text";
}

function changpass(){
    var accountpass =document.getElementById("accountpass").value;
    var accountpass2 =document.getElementById("accountpass2").value;
    if (accountpass===accountpass2){
        $.ajax({
            url:"changepass",
            type:"post",
            async: true,
            dataType: "json",
            data:{accountpass},
            success:function (data){
                if(data.inf==="修改成功"){
                    alert(data.inf);
                    location.href="login.html";
                }else{
                    alert(data.inf);
                }
            },
            error:function (data){
                alert("请求失败");
            }
        })
    }
}